package cn.tannn.ops.pwd.entity;

import cn.tannn.ops.common.pojo.JpaCommonBean;
import cn.tannn.ops.pwd.enums.EncryptType;
import cn.tannn.ops.pwd.enums.KeePassStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.annotations.ColumnDefault;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

/**
 * 密码管理器
 *
 * @author tnnn
 * @version V1.0
 * @date 2023-02-20 09:28
 */
@Entity
@Table(name = "kee_pass")
@Comment("密码管理器")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@DynamicUpdate
@DynamicInsert
@Schema(description = "密码管理器")
public class KeePassEntity extends JpaCommonBean<KeePassEntity> {

    /**
     * 分组
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("分组")
    @Schema(description = "分组")
    String groupings;

    /**
     * 密码标题
     */
    @Column(columnDefinition = "varchar(50)", nullable = false)
    @Comment("密码标题")
    @Schema(description = "密码标题")
    String title;

    /**
     * 用户名
     */
    @Column(columnDefinition = "varchar(50)")
    @Comment("用户名")
    @Schema(description = "用户名")
    String username;

    /**
     * 加密后的密码
     */
    @Column(columnDefinition = "varchar(200)", nullable = false)
    @Comment("加密后的密码")
    @Schema(description = "加密后的密码")
    String password;

    /**
     * 密码相关地址
     */
    @Column(columnDefinition = " varchar(100)")
    @Schema(description = "密码相关地址")
    @Comment("密码相关地址")
    String url;

    /**
     * 备注
     */
    @Column(columnDefinition = " varchar(100)")
    @Schema(description = "备注")
    @Comment("备注")
    String remark;

    /**
     * 加密方式
     */
    @Column(nullable = false)
    @Comment("加密方式")
    @Schema(description = "加密方式")
    @Enumerated(EnumType.STRING)
    EncryptType encryptType;

    /**
     * 加密次数
     */
    @Column(nullable = false)
    @Comment("加密次数[还没用]")
    @ColumnDefault("1")
    Integer encryptCount;

    /**
     * 状态
     *
     * @see KeePassStatus
     */
    @Column(nullable = false)
    @Comment("状态[0.有效，1.回收站]")
    @Enumerated(EnumType.ORDINAL)
    @Schema(description = "状态[0.有效，1.回收站]")
    @ColumnDefault("0")
    KeePassStatus status;

}
